From 77e1fe3493cd6b4ff21c02a3bbb1543e1d09a589 Mon Sep 17 00:00:00 2001 From: "emellor@leeni.uk.xensource.com" Date: Sun, 30 Oct 2005 13:48:34 +0100 Subject: [PATCH] Change the interface between XendRoot.get_network_script and Vifctl so that a list is passed rather than a single string. This expands the config-file interface so that parameters may be passed to the network scripts from the config file. Fix XendRoot._logError (missing asterisk before args parameter). In XendRoot, allow an empty configuration file. This makes it easier to unit test code reliant on XendRoot. Signed-off-by: Ewan Mellor --- tools/python/xen/xend/Vifctl.py | 3 ++- tools/python/xen/xend/XendRoot.py | 14 ++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/tools/python/xen/xend/Vifctl.py b/tools/python/xen/xend/Vifctl.py index 382cba5c04..9320930b27 100644 --- a/tools/python/xen/xend/Vifctl.py +++ b/tools/python/xen/xend/Vifctl.py @@ -32,4 +32,5 @@ def network(op): raise ValueError('Invalid operation: ' + op) script = XendRoot.instance().get_network_script() if script: - os.spawnl(os.P_WAIT, script, script, op) + script.insert(1, op) + os.spawnv(os.P_WAIT, script[0], script) diff --git a/tools/python/xen/xend/XendRoot.py b/tools/python/xen/xend/XendRoot.py index b51046a87b..564bc75ed3 100644 --- a/tools/python/xen/xend/XendRoot.py +++ b/tools/python/xen/xend/XendRoot.py @@ -114,7 +114,7 @@ class XendRoot: """ return self.components.get(name) - def _logError(self, fmt, args): + def _logError(self, fmt, *args): """Logging function to log to stderr. We use this for XendRoot log messages because they may be logged before the logger has been configured. Other components can safely use the logger. @@ -144,7 +144,10 @@ class XendRoot: config = sxp.parse(fin) finally: fin.close() - config.insert(0, 'xend-config') + if config is None: + config = ['xend-config'] + else: + config.insert(0, 'xend-config') self.config = config except Exception, ex: self._logError('Reading config file %s: %s', @@ -250,7 +253,9 @@ class XendRoot: s = self.get_config_value('network-script') if s: - return os.path.join(self.network_script_dir, s) + result = s.split(" ") + result[0] = os.path.join(self.network_script_dir, result[0]) + return result else: return None @@ -258,9 +263,6 @@ class XendRoot: def get_enable_dump(self): return self.get_config_bool('enable-dump', 'no') - def get_vif_bridge(self): - return self.get_config_value('vif-bridge', 'xenbr0') - def get_vif_script(self): return self.get_config_value('vif-script', 'vif-bridge') -- 2.30.2